package com.ant.storage.controller;


import com.ant.storage.common.ResultVo;
import com.ant.storage.pojo.DepartmentMsg;
import com.ant.storage.service.IDepartmentMsgService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hzd
 * @since 2023-08-09
 */
@RestController
@RequestMapping("/department-msg")
public class DepartmentMsgController {

    @Autowired
    private IDepartmentMsgService departmentMsgService;

    @ApiOperation(value = "获取部门信息列表")
    @GetMapping("/getDepartmentList")
    public ResultVo getDepartmentList()
    {
        return ResultVo.success("获取成功",departmentMsgService.list());
    }

    @ApiOperation(value = "保存或者修改")
    @PostMapping("/save")
    public ResultVo save(DepartmentMsg msg)
    {
        if(msg.getId()!=null){
            departmentMsgService.updateById(msg);
        }else{
            departmentMsgService.save(msg);
        }
        return ResultVo.success("操作成功");
    }


}
